package cc.rengu.redp.bizimpl.upmp.controller;


import cc.rengu.redp.bizimpl.upmp.domain.BDeviceAction;
import cc.rengu.redp.bizimpl.upmp.domain.BDeviceInfo;
import cc.rengu.redp.bizimpl.upmp.service.IBDeviceActionService;
import cc.rengu.redp.bizimpl.upmp.vo.BDeviceInfoVO;
import cc.rengu.redp.common.annotation.Log;
import cc.rengu.redp.common.controller.BaseController;
import cc.rengu.redp.common.domain.QueryRequest;
import cc.rengu.redp.common.exception.RedpException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author lizk
 */
@RestController
@RequestMapping("deviceAction")
@Slf4j
public class BDeviceActionController extends BaseController {

    @Autowired
    private IBDeviceActionService deviceActionService;


    @GetMapping
    public Map<String, Object> findByPage(QueryRequest queryRequest, BDeviceAction bDeviceAction) {
        return getDataTable(deviceActionService.findByPage(queryRequest, bDeviceAction));
    }

    @Log("修改设备")
    @PutMapping
//    @RequiresPermissions("brand:update")
    public void updateDevice(BDeviceAction bDeviceAction) throws RedpException {
        try {
            this.deviceActionService.updateDeviceAction(bDeviceAction);
        } catch (Exception e) {
            String message = e.getMessage();
            log.error(message, e);
            throw new RedpException(message);
        }
    }

}
